<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>15-画圆角矩形</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        canvas{
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="1280" height="600"></canvas>
    <script>
        var canvas = document.getElementById("canvas")
        var ctx = canvas.getContext("2d")

        // 注意 arcTo 方法原理
        // 1、定义一条 (50,100)>(50,250)的直线
        // 2、定义一条 (50,250)>(250,250)的直线
        // 3、以两条直线为圆的切线
        ctx.moveTo(50,100)
        ctx.arcTo(50,250,150,250,100)
        ctx.arcTo(650,250,650,50,100)

        ctx.moveTo(150,250)
        ctx.lineTo(650,250)
        ctx.stroke()
    </script>
</body>
</html>